/**
 * 
 */
package com.ermax.aircond.common.dao.impl;

import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.ermax.aircond.common.dao.ReadMachineDataDao;
import com.ermax.aircond.common.dao.WriteMachineDataDao;
import com.ermax.aircond.common.domain.ReadMachineData;
import com.ermax.aircond.common.domain.WriteMachineData;
import com.ermax.aircond.maintain.domain.Room;
import com.ermax.aircond.util.dao.AbstractHibernateDaoImpl;

/**
 * @author Eric, Maxwell
 *
 */
@Repository("readMachineDataDao")
public class ReadMachineDataDaoImpl extends AbstractHibernateDaoImpl<ReadMachineData> implements ReadMachineDataDao {

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1418603846702420259L;
	private static final Logger logger = Logger.getLogger(ReadMachineDataDaoImpl.class);
	
	private ReadMachineDataDaoImpl() {
		setClazz(ReadMachineData.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public ReadMachineData findMachineDateByNid(int nid) {
		Criteria criteria = this.getCurrentSession().createCriteria(ReadMachineData.class);
		criteria.add(Restrictions.eq("nid", nid));
		List<ReadMachineData> readMachineDatas = criteria.list();
		if(readMachineDatas.size() > 0){
			return readMachineDatas.get(0);
		}
		return null;
	}

	@SuppressWarnings("unchecked")
	public ReadMachineData getByNid(int nid) {
		
		Criteria criteria = getCurrentSession().createCriteria(ReadMachineData.class);
		if(isNotNull(nid)){
			criteria.add(Restrictions.eq("nid", nid));
		}
		
		List<ReadMachineData> results = criteria.list();
		
		if(results.size() > 0){
			return results.get(0);
		}
		
		return null;	
		
	}
	

	public ReadMachineData getById(int id) {
		return (ReadMachineData) this.getCurrentSession().get(ReadMachineData.class, id);
	}

	/* (non-Javadoc)
	 * @see com.ermax.aircond.util.dao.AbstractHibernateDaoImpl#findAll()
	 */
	@Override
	public List<ReadMachineData> findAll() {
		// TODO Auto-generated method stub
		return super.findAll();
	}

	/* (non-Javadoc)
	 * @see com.ermax.aircond.util.dao.AbstractHibernateDaoImpl#create(java.io.Serializable)
	 */
	@Override
	public void create(ReadMachineData entity) {
		// TODO Auto-generated method stub
		super.create(entity);
	}

	/* (non-Javadoc)
	 * @see com.ermax.aircond.util.dao.AbstractHibernateDaoImpl#update(java.io.Serializable)
	 */
	@Override
	public void update(ReadMachineData entity) {
		// TODO Auto-generated method stub
		super.update(entity);
	}

	/* (non-Javadoc)
	 * @see com.ermax.aircond.util.dao.AbstractHibernateDaoImpl#delete(java.io.Serializable)
	 */
	@Override
	public void delete(ReadMachineData entity) {
		// TODO Auto-generated method stub
		super.delete(entity);
	}

	/* (non-Javadoc)
	 * @see com.ermax.aircond.util.dao.AbstractHibernateDaoImpl#deleteById(java.lang.Long)
	 */
	@Override
	public void deleteById(Long entityId) {
		// TODO Auto-generated method stub
		super.deleteById(entityId);
	}
}
